<template>
  <div class="item-block">
    <div class="swiper-item" v-for="item in data" :key="item.id">
      <van-image width="100%" height="100%" lazy-load :src="item.imagePath">
        <template v-slot:error>加载失败</template>
      </van-image>
      <!-- <img :src="item.imagePath" alt="" /> -->
      <div class="swiper-item-des">
        <van-badge :content="diasheMaps[item.id]">
          <span>{{ item.name }}</span>
        </van-badge>
        <span>{{ item.price }}</span>
        <button @click="add(item)" :data-info="JSON.stringify(item)">添加</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['data', "pageIndex"],
  computed: {
    diasheMaps () {
      return this.$store.state.cartShops_Maps
    }
  },
  methods: {
    add (item) {

      console.log("%c Line:20 🥝 添加ADD", "font-size:18px;color:#ffffff;background:#8c7ae6");
      // const page = this.pageIndex
      this.$store.commit('add_diashes', item);
    }
  },
}
</script>

<style lang="less" scoped>
.item-block {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
}
.swiper-item {
  width: 33%;
  height: 100px;
  position: relative;
  .swiper-item-des {
    position: absolute;
    left: 0;
    bottom: 0;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    button {
      color: red;
      cursor: pointer;
    }
  }
  img {
    width: 100%;
  }
}
</style>